/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import pojo.TimeTable;
import ulti.HibernateUtil;

/**
 *
 * @author HungDQ
 */
public class TimeTableDAO {
    //<editor-fold defaultstate="collapsed" desc="1. Xem thông tin timetable">

    public static List<TimeTable> getTimetable() {
        List<TimeTable> timeTables = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        try {
            String hql = "from TimeTable";
            Query query = session.createQuery(hql);
            timeTables = query.list();
        } catch (HibernateException ex) {
            System.err.println(ex);
        }
        return timeTables;
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Lấy thông tin TimeTable thông qua id">
    public static TimeTable getTimeTableByID(String id) {
        TimeTable table = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        try {
            table = (TimeTable) session.get(TimeTable.class, id);
        } catch (HibernateException ex) {
            System.err.println(ex);
        }
        return table;
    }
    //</editor-fold>
}
